package day20180129.designMode.six_Prototype;

/**
 * Created by 14394 on 2018/1/29.
 */

//实现Product接口，实现复制
public class UnderLinePen implements Product {

    private char ulchar;

    public UnderLinePen(char ulchar) {
        this.ulchar = ulchar;
    }

    @Override
    public void use(String s) {//子类之间有区别的方法
        int length= s.getBytes().length;
        System.out.println("\"" + s+ "\"");
        for (int i =0; i<length;i++){
            System.out.print(ulchar);
        }
        System.out.println("");
    }

    @Override
    public Product createClone() {
        Product p = null;
        try {
            p = (Product) clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return p;
    }
}
